home *** CD-ROM | disk | FTP | other *** search
- #: 137059 S4/Programming (S)
- 24-Oct-87 04:11:56
- Sb: #EXEC curiosity
- Fm: Charles Lazo III 72210,17
- To: all
-
- I have included in this message the entire listing of a program that I wrote
- as a test. The program works fine. What I would like to know is why do
- mapmem, pmap, and even rmap when you catch it right all show that the program
- intercepts int 22h when it was only written to take int 21h? My own
- investigation came to a standstill when I couldn't see where the int 22h
- pointed (DOS takes it so debug wouldn't work, Periscope says /v:22 is
- illegal.) <sigh>
-
- name execbeep
-
- dp equ dword ptr
- of equ offset
-
- code segment
- assume cs:code
- org 100h
-
- begin: jmp start
-
- old_int21 dw 2 dup(?) ; former int 21h
-
- beep proc ; beep the speaker
- push ax ; save
- push cx
- in al,97 ; get port values
- and al,0feh ; turn speaker on
- out 97,al
- mov cx,55 ; cycles to cx
- more_sound: push cx ; save cycles
- xor al,2 ; flip push/pull
- out 97,al
- mov cx,111 ; wait
- part1: loop part1
- xor al,2 ; flip push/pull
- out 97,al
- mov cx,111 ; wait
- part2: loop part2
- pop cx
- loop more_sound
- pop cx ; restore
- pop ax
- ret
- beep endp
-
- new_int21 proc far
- cmp ah,4bh ; EXEC function?
- je exec_beep ; yes, call EXEC, then beep
- jmp dp cs:old_int21 ; no, pass it on
-
- exec_beep: pushf ; imitate an interrupt
- call dp cs:old_int21 ; in calling EXEC
- call beep ; beep after EXEC
- iret ; return to caller
- new_int21 endp
-
- start: mov ax,3521h ; get int 21h
- int 21h
- mov old_int21,bx ; store offset
- mov old_int21+2,es ; store segment
- mov dx,of new_int21 ; ds:dx -> new int 21h
- mov ax,2521h
- int 21h
- mov dx,of start ; discard excess
- add dx,0fh
- shr dx,1
- shr dx,1
- shr dx,1
- shr dx,1
- mov ax,3100h ; keep process
- int 21h
-
- code ends
- end begin
-
- #: 137076 S4/Programming (S)
- 24-Oct-87 08:37:15
- Sb: #137059-EXEC curiosity
- Fm: Chip Rabinowitz (MSOFT) 76703,350
- To: Charles Lazo III 72210,17 (X)
-
- Charles:
-
- Interrupt 22 is the MS-DOS Terminate Address. The currently executing program
- under MS-DOS *always* has this address ......
-
- Chip
-
- #: 137086 S4/Programming (S)
- 24-Oct-87 10:25:34
- Sb: #137076-#EXEC curiosity
- Fm: Charles Lazo III 72210,17
- To: Chip Rabinowitz (MSOFT) 76703,350 (X)
-
- Ok, true, but pmap, et al always show EXECBEEP as having this vector even if
- any number of TSR's are loaded after--how come?
-
- Still, it is not true as I stated that "The program works fine." When I run a
- sequence like:
-
- C>MARK
- C><possibly other loads>
- C>RELEASE
-
- The machine hangs at the end. When I tried to bring up Periscope at this
- point I got PARITY CHECK 2.
-
- #: 137090 S4/Programming (S)
- 24-Oct-87 10:58:55
- Sb: #137086-EXEC curiosity
- Fm: Chip Rabinowitz (MSOFT) 76703,350
- To: Charles Lazo III 72210,17 (X)
-
- Charles:
-
- I dunno, but this could be the problem. The FLAGS register is significant for
- INT 21 ... and your INT21 handler destroys it: You have:
-
- exec_beep: pushf ; imitate an interrupt
- call dp cs:old_int21 ; in calling EXEC
- call beep ; beep after EXEC
- iret ; return to caller
-
- if you change this to:
-
- exec_beep: pushf ; imitate an interrupt
- call dp cs:old_int21 ; in calling EXEC
- pushf ;save return flags
- call beep ; beep after EXEC
- popf ;original flags return
- ret 2 ; return to caller
-
- it might work better ....
-
- Chip
-
- #: 137388 S4/Programming (S)
- 25-Oct-87 21:04:23
- Sb: #137090-#EXEC curiosity
- Fm: Charles Lazo III 72210,17
- To: Chip Rabinowitz (MSOFT) 76703,350 (X)
-
- Chip, thanks, I made that change, but still no go. The problem is that int 22h
- is made to point to my code exactly 16 bytes from the start of the int 21h
- handler. Ie, normally int 22h points to a location in COMMAND when EXEC is in
- effect, but EXECBEEP's interaction with DOS makes int 22h point to a paragraph
- beyond the int 21h handler. This is done by DOS after (or during) the function
- 31h termination. I was able to determine this by using PEPORE, a program that
- Don suggested (a popup memory dump program). It is RELEASE's attempt to
- replace the terminate vector to point to EXECBEEP's code that causes the crash
- mentioned before (verified by having a valid termination of RELEASE when the
- int 22h vector in the vector table kept by MARK was changed to point to its
- normal location in COMMAND).
-
- Using int 27h termination results in the same effect and so does the direct
- replacement of int 21h by storing segment and offset in the int table.
-
- At this point the only thing that I can think to do is use PS's run program and
- GT after termination of EXECBEEP in two different forms--one which alters int
- 21h and one which doesn't--then note any difference in the trace back buffer.
- Have a better suggestion?
-
- #: 137396 S4/Programming (S)
- 25-Oct-87 21:59:32
- Sb: #137388-EXEC curiosity
- Fm: Chip Rabinowitz (MSOFT) 76703,350
- To: Charles Lazo III 72210,17 (X)
-
- Charles:
-
- I don't know .. and its been a long day here. I'll try to look at your code
- this week and see if I can find anything. Give me a nudge Tuesday PM if you
- don't here from me.
-
- Chip
-
- #: 137874 S4/Programming (S)
- 28-Oct-87 13:29:28
- Sb: #137396-#EXEC curiosity
- Fm: Charles Lazo III 72210,17
- To: Chip Rabinowitz (MSOFT) 76703,350 (X)
-
- Chip,
-
- (Whew--that was a long haul! But in the end it was simple.)
-
- Turns out that the EXEC call automatically sets the int 22h vector to the code
- immediately succeeding the int 21h call for EXEC while EXEC is in progress.
- Presumably because this is the address to which execution will pass if there
- is an abnormal termination. I tried every thing I could think of to get
- around this difficulty even (heaven forbid!) changing the code after the EXEC
- call into a jump to the 21h handler where it was restored to the original
- value before the handler exited (even such drastic action did not work; there
- were reentrancy problems). Finally, taking a break after that fiasco to
- collect my thoughts it occurred to me that something which I had thought about
- before but rejected (because it does not solve the problem of eg, "Bad command
- or file name"--but that's ok!) was in fact the solution. YOU SIMPLY TRAP THE
- RETURN CODE CALL:
-
- new_int21 proc far
- cmp ah,4bh ; EXEC function?
- je exec_beep ; yes, beep, then call EXEC
- cmp ah,4dh ; request to get return code?
- je retc_beep ; yes, beep then get return code
- jmp dp cs:old_int21 ; no, pass it on
-
- exec_beep: call beep ; beep before EXEC
- jmp dp cs:old_int21 ; go do EXEC
-
- retc_beep: call beep ; beep after EXEC
- jmp dp cs:old_int21 ; go get return code
- new_int21 endp
-
- Thanks for responding, I appreciate that I can tap your knowledge on these
- things.
-
- #: 137880 S4/Programming (S)
- 28-Oct-87 15:38:46
- Sb: #137874-EXEC curiosity
- Fm: Chip Rabinowitz (MSOFT) 76703,350
- To: Charles Lazo III 72210,17 (X)
-
- Anytime I can help, charles. Thanks for the feedback ...
-
- Chip